﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AimGameLibrary.ScreenManager;

namespace AimGameLibrary.GameObject
{
    public class GameScreenControl : BaseGameObject
    {
        String NameNextScreen;
        Boolean LoadingIsSlow;
        Double[] FaceTime;

        GameScreen gameScreen;

        public GameScreenControl(GameScreen gameScreen)
        {
            this.FaceTime = new Double[2];
            this.gameScreen = gameScreen;
        }

        public override void LoadData(Identification getdata, int IndexData, NodeData node)
        {
            InputMode = (NodeInputMode)getdata.Items.GetValue(IndexData + 1);
            if (InputMode == NodeInputMode.AddScreen)
            {
                NameNextScreen = (String)getdata.Items.GetValue(IndexData + 2);
            }
            else if (InputMode == NodeInputMode.LoadingScreen)
            {
                NameNextScreen = (String)getdata.Items.GetValue(IndexData + 2);
                LoadingIsSlow = (Boolean)getdata.Items.GetValue(IndexData + 3);
            }
        }

        public override void UpdateGameTime(Microsoft.Xna.Framework.GameTime gametime)
        {
            //base.UpdateGameTime(gametime);
            if (InputMode == NodeInputMode.AddScreen)
                    gameScreen.ScreenManager.AddScreen(new AimGameScreen(NameNextScreen), null);
            else if (InputMode == NodeInputMode.ExitScreen)
                    gameScreen.ExitScreen();
            else if (InputMode == NodeInputMode.ExitGame)
                    gameScreen.ScreenManager.Game.Exit();
            else if(InputMode == NodeInputMode.LoadingScreen)
                    LoadingScreen.Load(gameScreen.ScreenManager, LoadingIsSlow, null, new AimGameScreen(NameNextScreen));
            
        }
    }
}
